package com.zl.easybuy.vo;

import lombok.Getter;

import java.util.List;
@Getter
public class ReaultVo<T> {
    private int code;//状态码
    private String msg;//提示信息
    private List<T> datas;//数据

    public ReaultVo(ResultCode resultCode,List<T> datas){
        this.code=resultCode.getCode();
        this.msg=resultCode.getMsg();
        this.datas=datas;
    }
    public ReaultVo(int code,String msg){
        this.msg=msg;
        this.code=code;
    }
    //成功携带数据
    public ReaultVo(List<T> datas){
        this(ResultCode.SUCCESS,datas);
    }
    public ReaultVo(ResultCode resultCode){this(resultCode,null);}
    //成功登录不携带数据
    public static ReaultVo success(ResultCode resultCode){
        return new ReaultVo(resultCode,null);
    }
    //登录失败
    public static ReaultVo fail(ResultCode resultCode){
        return new ReaultVo(resultCode,null);
    }
}
